package com.huaxin.device.models;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.huaxin.device.dto.enums.AlarmLevel;
import com.huaxin.device.dto.enums.AlarmType;
import com.huaxin.hxenum.enums.ComparisonOperator;
import com.huaxin.hxenum.enums.Unit;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 报警阈值规则
 */
@Data
@TableName("alarm_threshold_rules")
@EqualsAndHashCode(callSuper = true)
public class AlarmThresholdRule extends BaseModel {

    /**
     * 所属模板ID
     */
    @TableField(value = "template_id")
    @Schema(description = "所属模板ID", example = "876e5432-e12d-32c1-b654-321098765432")
    private String templateId;

    /**
     * 报警类型
     */
    @TableField(value = "alarm_type")
    @Schema(description = "报警类型", example = "voltage")
    private AlarmType alarmType;

    /**
     * 监控字段
     */
    @TableField(value = "metric_field")
    @Schema(description = "监控字段", example = "")
    private String metricField;

    /**
     * 比较操作：>, >=, <, <=, =, !=
     */
    @TableField(value = "comparison_op")
    @Schema(description = "比较操作", example = "gt")
    private ComparisonOperator comparisonOp;

    /**
     * 阈值（字符串存储，兼容数字/布尔）
     */
    @TableField(value = "threshold_value")
    @Schema(description = "阈值", example = "10.5")
    private String thresholdValue;

    /**
     * 单位，如：A, V, ℃, %
     */
    @TableField(value = "unit")
    @Schema(description = "单位", example = "A")
    private Unit unit;

    /**
     * 报警等级
     */
    @TableField(value = "alarm_level")
    @Schema(description = "报警等级", example = "1")
    private AlarmLevel alarmLevel;

    /**
     * 持续时间（秒），如：持续10秒才触发
     */
    @TableField(value = "duration_sec")
    @Schema(description = "持续时间（秒）", example = "10")
    private Integer durationSec;

    /**
     * 冷却时间（秒），防止重复报警
     */
    @TableField(value = "cooldown_sec")
    @Schema(description = "冷却时间（秒）", example = "300")
    private Integer cooldownSec;

    /**
     * 是否启用
     * 0: 禁用，1: 启用
     * 默认为禁用
     */
    @TableField(value = "is_enabled")
    @Schema(description = "是否启用", example = "1")
    private Boolean isEnabled = false;

    /**
     * 描述
     */
    @TableField(value = "description")
    @Schema(description = "描述", example = "电流超过10A触发报警")
    private String description;
}